home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000011_icon-group-sender _Mon Jan 6 11:23:17 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Mon, 6 Jan 1997 13:49:15 MST
  2. Date: Mon, 6 Jan 1997 11:23:17 -0800
  3. Message-Id: <199701061923.LAA16481@dfw-ix3.ix.netcom.com>
  4. X-Sender: bobalex@popd.ix.netcom.com
  5. X-Mailer: Windows Eudora Pro Version 2.1.2
  6. Mime-Version: 1.0
  7. Content-Type: text/plain; charset="us-ascii"
  8. To: robinstu@ohsu.edu, Icon Group <icon-group@cs.arizona.edu>
  9. From: Bob Alexander <bobalex@ix.netcom.com>
  10. Subject: Re: Another Question from the Neophyte
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12. Status: RO
  13. Content-Length: 1016
  14.  
  15. >But I've run into a new problem.  I have found numerous options for
  16. >scanning forward in a string, but I haven't found a good way to move
  17. >backwards, besides first reversing a string and then scanning forward
  18. >(which is functionally scanning backwards).
  19.  
  20. Here's a way to solve your problem without reverse scanning:
  21.  
  22. procedure main()
  23.   while line := read() do line ? {
  24.     every i := 0 | upto(' ')
  25.     write(line[i + 1:0])
  26.   }
  27. end
  28.  
  29. Scanning in Icon is most definitely biased toward left-to-right scanning,
  30. however the cursor (&pos) can be moved "backward" for certain problems.
  31. E.g. the argument to move() can be negative, and tab() can take you toward
  32. the left, too.  You can also write your own scanning functions to move the
  33. cursor backward.  This might invoke the wrath of some scanning purists, but
  34. it works for some things.
  35.  
  36. However, as shown above, sometimes there is a completely different way of
  37. approaching a problem that appears to involve backward scanning.
  38.  
  39. -- Bob Alexander
  40.    bobalex@ix.netcom.com
  41.  
  42.